package com.tiger.web.controller.transaction;

import com.tiger.common.annotation.Log;
import com.tiger.common.core.controller.BaseController;
import com.tiger.common.core.domain.AjaxResult;
import com.tiger.common.core.page.TableDataInfo;
import com.tiger.common.enums.BusinessType;
import com.tiger.transaction.domain.RentalApply;
import com.tiger.transaction.service.IRentalApplyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 【租房申请】Controller
 *
 * @author standard
 * @date 2022-09-20
 */
@Api(tags = "租房申请")
@RestController
@RequestMapping("/system/rentalApply")
public class RentalApplyController extends BaseController {
    @Autowired
    private IRentalApplyService rentalApplyService;

    /**
     * 查询【租房申请】列表
     */
    @ApiOperation(value = "查询【租房申请】列表")
    //@PreAuthorize("@ss.hasPermi('system:apply:list')")
    @GetMapping("/list")
    public TableDataInfo list(RentalApply rentalApply) {
        startPage();
        List<RentalApply> list = rentalApplyService.selectRentalApplyList(rentalApply);
        return getDataTable(list);
    }


    /**
     * 获取【租房申请】详细信息
     */
    @ApiOperation(value = "获取【租房申请】列详细信息")
    //@PreAuthorize("@ss.hasPermi('system:apply:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(rentalApplyService.selectRentalApplyById(id));
    }

    /**
     * 新增【租房申请】
     */
    @ApiOperation(value = "新增【租房申请】")
    //@PreAuthorize("@ss.hasPermi('system:apply:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody RentalApply rentalApply) {
        return toAjax(rentalApplyService.insertRentalApply(rentalApply));
    }

    /**
     * 修改【租房申请】
     */
    @ApiOperation(value = "审核")
    //@PreAuthorize("@ss.hasPermi('system:apply:edit')")
    @Log(title = "【租房申请】", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody RentalApply rentalApply) {
        return toAjax(rentalApplyService.updateRentalApply(rentalApply));
    }

    /**
     * 删除【租房申请】
     */
//    @ApiOperation(value = "删除【请填写功能名称】")
    //@PreAuthorize("@ss.hasPermi('system:apply:remove')")
    @Log(title = "【租房申请】", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(rentalApplyService.deleteRentalApplyByIds(ids));
    }
}
